package com.example.yunJie.digitalSentry.mapper.one;


import com.example.yunJie.digitalSentry.entity.ShiftDateEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.io.Serializable;
import java.util.List;

public interface ShiftDateMapper {
//    @Insert("<script>insert into sz_shift_date(dateId,shiftId)\n" +
//            "        values(#{dateId},#{shiftId})</script>")
    int insert(ShiftDateEntity shiftDateEntity);

//    @Update("<script>update sz_shift_date\n" +
//            "        <trim prefix=\"SET\" suffixOverrides=\",\">\n" +
//            "            <if test=\"dateId != null and dateId != ''\">dateId = #{dateId},</if>\n" +
//            "            <if test=\"shiftId != null and shiftId != ''\">shiftId = #{shiftId},</if>\n" +
//            "        </trim>\n" +
//            "        where id = #{id}</script>")
    int update(ShiftDateEntity shiftDateEntity);

//    @Delete("<script>delete from sz_shift_date where id = #{Id}</script>")
    int deleteById(Serializable id);
//    @Delete("<script> delete from sz_shift_date where shiftId = #{shiftId}</script>")
    int deleteByShiftId(String shiftId);
//    @Delete("<script>delete from sz_shift_date where id in\n" +
//            "        <foreach collection=\"array\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
//            "            #{id}\n" +
//            "        </foreach></script>")
    int deleteIdList(List<Integer> idList);

//    @Select("<script>select  *\n" +
//            "        from sz_shift_date\n" +
//            "        where id = #{id}</script>")
    ShiftDateEntity findId(Serializable id);

//    @Select("<script>select * from sz_shift_date\n" +
//            "        <where>\n" +
//            "            <if test=\"shiftId != null and shiftId != ''\">and shiftId = #{shiftId} </if>\n" +
//            "            <if test=\"dateId != null and dateId != ''\">and dateId = #{dateId} </if>\n" +
//            "        </where></script>")
    ShiftDateEntity find(ShiftDateEntity shiftDateEntity);
//    @Select("<script>select  sz_shift.id,sz_shift.shiftName,sz_shift.startTime,sz_shift.endTime,sz_shift.marketId,sz_shift.postId,postName,marketName,sz_shift_period.periodId,sz_period.`mode`,group_concat(date) as attendanceDetails  from sz_shift_date\n" +
//            "                left join sz_shift on sz_shift.id = sz_shift_date.shiftId\n" +
//            "                left join sz_date on sz_date.id = sz_shift_date.dateId\n" +
//            "                left join sz_post on sz_post.id = sz_shift.postId\n" +
//            "                left join sz_market on sz_market.id = sz_shift.marketId\n" +
//            "                left join sz_shift_period on sz_shift.id = sz_shift_period.shiftId\n" +
//            "                left join sz_period on sz_shift_period.periodId = sz_period.id\n" +
//            "        <where>\n" +
//            "            <if test=\"shiftId != null and shiftId != ''\">and shiftId = #{shiftId}</if>\n" +
//            "            <if test=\"marketName != null and marketName != ''\">and sz_market.marketName = #{marketName}</if>\n" +
//            "            <if test=\"postName != null and postName != ''\">and sz_post.postName = #{postName}</if>\n" +
//            "            <if test=\"shiftName != null and shiftName != ''\">and sz_shift.shiftName = #{shiftName}</if>\n" +
//            "        </where>\n" +
//            "        group by sz_shift.id,sz_shift.shiftName,sz_shift.startTime,sz_shift.endTime,sz_shift.marketId,sz_shift.postId,postName,marketName,sz_shift_period.periodId,sz_period.`mode`\n</script>")
    List<ShiftDateEntity> findAll(ShiftDateEntity shiftDateEntity);

    List<ShiftDateEntity> findByShiftId(String shiftId);

}
